Skip to content

gh-112532: Use separate mimalloc heaps for GC objects#113263

Merged
corona10 merged 3 commits intopython:mainfrom
colesbury:mimalloc-heaps
Dec 26, 2023
Merged

gh-112532: Use separate mimalloc heaps for GC objects#113263
corona10 merged 3 commits intopython:mainfrom
colesbury:mimalloc-heaps

Conversation

@colesbury
Copy link
Contributor

@colesbury colesbury commented Dec 18, 2023

In --disable-gil builds, we now use four separate heaps in preparation for when we will use mimalloc to find GC objects when the GIL is disabled. This requires making a few changes to mimalloc:

  • mi_heap_t and mi_tld_t initialization is split from allocation. This allows us to have a mi_tld_t per-PyThreadState, which is important to keep interpreter isolation, since the same OS thread may run in multiple interpreters (using different PyThreadStates.)

  • Heap abandoning (mi_heap_collect_ex) can now be called from a different thread than the one that created the heap. This is necessary because we may clear and delete the containing PyThreadStates from a different thread during finalization and after fork().

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants